<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/page/common/public.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta content="max-age=0" http-equiv="Cache-Control" />
<meta content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=2.0" name="viewport" />
<meta content="telephone=no" name="format-detection" />
<meta content="240" name="MobileOptimized" />
<title>问卷调查</title>
<link href="${skin }/public.css" rel="stylesheet" type="text/css" />
<link href="${skin }/szc_touzhu.css" rel="stylesheet" type="text/css" />
<link href="${skin }/hemai.css" rel="stylesheet" type="text/css" />
<link href="${skin }/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${path }/js/jquery-1.4.2.min.js?v=${v}"></script>
<script type="text/javascript" src="${path }/js/helper.js?v=${v}"></script>
<link rel="stylesheet" href="${path }/page/vote/css/style.css" />
<script type="text/javascript">
$(function(){
	if("NO" == $('#isVoteLogin').val())
	{
		megse('请先登录！');
		return false;
	}
	if("NO" == $('#isSure').val())
	{
		//alert('调查已截止,谢谢参与！');
		megse('调查已截止,谢谢参与！');
		return false;
	}
	else if("NO" == $('#isRestrict').val())
	{
		//alert('每天只能投票一次,谢谢参与！');
		megse('只能投票一次,谢谢参与！');
		return false;
	}
	
	
});

function toSubmit()
{
	if("NO" == $('#isVoteLogin').val())
	{
		megse('请先登录！');
		return false;
	}
	if("NO" == $('#isSure').val())
	{
		//alert('调查已截止,谢谢参与！');
		megse('调查已截止,谢谢参与！');
		return false;
	}
	var problemLength = $('#problemLength').val();
	var optionList = "";
	for(var i = 1;i <= problemLength; i++)
	{
		var optionType = $('#optionType'+i).val();
		var problemId = $('#problemId'+i).val();
		if('RADIO' == optionType) 
		{	
			var optionVal = $("input[id='option"+i+"']:checked").val(); 
			if(undefined == optionVal || '' == optionVal)
			{
				//alert('请选择第'+i+'道问题！');
				megse('请选择第'+i+'道问题！');
				return false;
			}
			var textVal = $('#text_'+optionVal).val();
			if(undefined != textVal && '' != textVal)
			{
				optionList += problemId + "#" + optionVal + "#"+ textVal +";";
			}
			else
			{
				optionList += problemId + "#" + optionVal + ";";
			}
		}
		else 
		{
			var checkBoxList = '';
			$("input[name='option"+i+"']").each(function(){
				if($(this).attr("checked") == true)
				{
					checkBoxList += $(this).val()+',';
				}
			}); 
			
			if('' == checkBoxList)
			{
				//alert('请选择第'+i+'道问题！');
				megse('请选择第'+i+'道问题！');
				return false;
			}
			optionList += problemId + "#" + checkBoxList + ";";
		}
	}

	/* var player = $('#player').val();
	if('' == player) 
	{
		alert('联系方式(QQ,电话,邮箱) 方便我们客服及时为您服务！');
		return false;
	}

	// 手机号码
	if('MSN' == $('#linkType').val())
	{
		var pattern = /(^1[3458]{1}[0-9]{9}$)|(^[0-9]{8}$)/;
		if (!pattern.test(player)) {
			alert("手机号码格式不正确！");
			return false;
		}
	}// QQ
	else if('QQ' == $('#linkType').val())
	{
		var pattern = new RegExp(/^\d+$/);
		if (!pattern.test(player)) {
			alert("QQ号码格式不正确！");
			return false;
		}
	}// 邮箱
	else if('MAIL' == $('#linkType').val())
	{
		var pattern = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
		if (!pattern.test(player)) {
			alert("邮箱格式不正确！");
			return false;
		}
	}
	
	if('' == $('#remark').val())
	{
		alert('请填写您认为开心彩票网可以改进的有哪些方面？');
		return false;
	} */

	$('#option').val(optionList);
	// 提交
	$("#inquiryform").submit();
}

function selOptionType(_this,optionType,_inex){
	if(optionType=="RADIO"){
		$("#sel_"+_inex).find("div").attr("class","ui-radio");
		$("#sel_"+_inex).find("a").attr("class","jqradio");
		$(_this).attr("class","ui-radio focuschoice"); 
		$(_this).find("a").attr("class","jqradio jqchecked");
		$("input[name='option"+_inex+"']").attr("checked","");
		$(_this).find("input").attr("checked","true");
	}else if(optionType=="CHECKBOX"){
		var optionVal = $(_this).find("input").attr("checked");
		if(optionVal){
			$(_this).attr("class","ui-checkbox"); 
			$(_this).find("a").attr("class","jqcheck");
			$(_this).find("input").attr("checked","");
		}else{
			$(_this).attr("class","ui-checkbox focuschoice"); 
			$(_this).find("a").attr("class","jqcheck jqchecked");
			$(_this).find("input").attr("checked","true");
		}
	}
}

function megse(str){
	$("#megse").text(str);
}
</script>
</head>

<body>
<div style="margin:16px 0 0 16px; text-indent:20pt;">
    尊敬的用户，为了更好地了解彩民的习惯行为及吸取意见，以便我们未来提供更好的产品服务，请您抽出5分钟时间完成本次问卷调查，非常感谢您的参与。
</div>
<form id="inquiryform" action="/vote/inquiryVote.htm" method="post">
<input type="hidden" name="isSure" id="isSure" value="${isSure }"/>
<input type="hidden" name="problemLength" id="problemLength" value="${problemLength }"/>
<input type="hidden" name="inquiryId" id="inquiryId" value="${inquiry.id }"/>
<input type="hidden" name="isRestrict" id="isRestrict" value="${isRestrict }"/>
<input type="hidden" name="isVoteLogin" id="isVoteLogin" value="${isVoteLogin }"/>
<input type="hidden" name="option" id="option"/>
<input type="hidden" name="userId" value="${userId}"/>

<div id="divContent">
	<div id="divQuestion">
		<fieldset class='fieldset' style='' id='fieldset1' >
			<c:forEach items="${problemList}" var="problem" varStatus="sta">
            <div class='field ui-field-contain' id='div1'  data-role='fieldcontain' type='3'>
           		<div class='field-label'>${sta.count}、${problem.title }<input type="hidden" name="problemId${sta.count}" id="problemId${sta.count}" value="${problem.id }"/></div>
                <div class='ui-controlgroup' id="sel_${sta.count}">
                	<input type="hidden" id="optionType${sta.count}" value="${problem.optionType }"/>
                	<c:forEach items="${problem.options}" var="option">
                    	<c:if test="${problem.optionType=='RADIO'}">
                    	 <div class='ui-radio' onclick="selOptionType(this,'${problem.optionType}','${sta.count}')">
                    	 <span class='jqradiowrapper'>
                    	</c:if>
                    	<c:if test="${problem.optionType=='CHECKBOX'}">
                    	<div class='ui-checkbox' onclick="selOptionType(this,'${problem.optionType}','${sta.count}')">
                        <span class='jqcheckwrapper'>
                    	</c:if>
                        	<input type="${problem.optionType}" style='display:none;' value="${option.id }" id="option${sta.count}" name="option${sta.count}"/>
                        	<c:if test="${problem.optionType=='RADIO'}">
                        	<a class='jqradio' href="javascript:void(0);"></a>
                        	</c:if>
                        	<c:if test="${problem.optionType=='CHECKBOX'}">
                        	<a class='jqcheck' href="javascript:void(0);"></a>
                        	</c:if>
                        	<c:if test="${option.isEdit == '1'}">
                        	</c:if>
                        </span>
                        <label for='q1_1'>${option.title}</label>
                    </div>
                    </c:forEach>
                </div>
                <div class='errorMessage'></div>
            </div>
            </c:forEach>
    	</fieldset>
	</div>
	<div id="divSubmit" style="padding: 10px;">
		<div><span id='megse' style="color: red;font-size: 20px;"></span></div>
		<a id="ctlNext" href="javascript:void(0)" onclick="toSubmit();" class="button orange">提交答卷</a>
	</div>    
</div>	
</form>	
</body>
</html>